import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    name: '/login',
    component: () => import('@/views/login'),
    hidden: true,
    meta: { hidden: true }
  },
  {
    path: '/invites',
    name: '/invites',
    component: () => import('@/views/invites'),
    hidden: true,
    meta: { hidden: true }
  },
  {
    path: '/enterSelf',
    name: '/enterSelf',
    component: () => import('@/views/enterSelf'),
    hidden: true,
    meta: { hidden: true }
  },
  {
    path: '/invitesmore',
    name: '/invitesmore',
    component: () => import('@/views/invitesmore'),
    hidden: true,
    meta: { hidden: true }
  },
  {
    name: '/',
    path: '/',
    redirect: '/home',
    component: Layout,
    children: [
      {
        name: '/home',
        path: '/home',
        title: '首页',
        meta: { title: '首页', directory: true, icon: require('@/assets/menu-icon/首页(未选中）.png'), activeIcon: require('@/assets/menu-icon/首页(选中).png') },
        component: () => import('@/views/home/home')
      }
    ]
  },
  {
    name: '/project',
    path: '/project',
    redirect: '/project/project',
    component: Layout,
    meta: { title: '项目中心', directory: true, icon: require('@/assets/menu-icon/项目中心（未选中）.png'), activeIcon: require('@/assets/menu-icon/项目中心（选中）.png') },
    children: [
      {
        name: '/project/center',
        path: '/project/center',
        title: '项目中心',
        meta: { title: '项目中心', icon: require('@/assets/menu-icon/项目中心（未选中）.png'), activeIcon: require('@/assets/menu-icon/项目中心（选中）.png') },
        component: () => import('@/views/project/center')
      },
      {
        name: '/project/add',
        path: '/project/add',
        title: '新增项目',
        hidden: true,
        meta: { title: '新增项目', icon: require('@/assets/menu-icon/项目中心（未选中）.png'), activeIcon: require('@/assets/menu-icon/项目中心（选中）.png') },
        component: () => import('@/views/project/center/add')
      },
      {
        name: '/project/detail',
        path: '/project/detail',
        title: '项目中心详情',
        hidden: true,
        meta: { title: '项目中心详情', icon: require('@/assets/menu-icon/项目中心（未选中）.png'), activeIcon: require('@/assets/menu-icon/项目中心（选中）.png') },
        component: () => import('@/views/project/center/detail')
      },
      {
        name: '/project/static',
        path: '/project/static',
        title: '汇总统计',
        meta: { title: '汇总统计', icon: require('@/assets/menu-icon/项目中心（未选中）.png'), activeIcon: require('@/assets/menu-icon/项目中心（选中）.png') },
        component: () => import('@/views/project/static')
      }
    ]
  },
  {
    name: '/engineering',
    path: '/engineering',
    redirect: '/engineering',
    component: Layout,
    meta: { title: '工程中心', directory: true, icon: require('@/assets/menu-icon/项目中心（未选中）.png'), activeIcon: require('@/assets/menu-icon/项目中心（选中）.png') },
    children: [
      {
        name: '/engineering/engineering',
        path: '/engineering/engineering',
        title: '工程中心',
        meta: { title: '工程中心', icon: require('@/assets/menu-icon/项目中心（未选中）.png'), activeIcon: require('@/assets/menu-icon/项目中心（选中）.png') },
        component: () => import('@/views/engineering/center')
      },
      {
        name: '/engineering/meeting',
        path: '/engineering/meeting',
        title: '组织参会',
        meta: { title: '组织参会', icon: require('@/assets/menu-icon/项目中心（未选中）.png'), activeIcon: require('@/assets/menu-icon/项目中心（选中）.png') },
        component: () => import('@/views/engineering/meeting')
      }
    ]
  },
  {
    name: '/review',
    path: '/review',
    redirect: '/review',
    component: Layout,
    meta: { title: '评审申请', directory: true, icon: require('@/assets/menu-icon/评审申请（未选中）.png'), activeIcon: require('@/assets/menu-icon/评审申请（选中）.png') },
    children: [
      {
        name: '/review/review',
        path: '/review/review',
        title: '评审申请',
        meta: { title: '评审申请', icon: require('@/assets/menu-icon/评审申请（未选中）.png'), activeIcon: require('@/assets/menu-icon/评审申请（选中）.png') },
        component: () => import('@/views/review/apply')
      },
      {
        name: '/review/center',
        path: '/review/center',
        title: '项目中心',
        meta: { title: '项目中心', icon: require('@/assets/menu-icon/评审申请（未选中）.png'), activeIcon: require('@/assets/menu-icon/评审申请（选中）.png') },
        component: () => import('@/views/review/center')
      }
    ]
  },
  {
    name: '/meeting',
    path: '/meeting',
    redirect: '/meeting/apply',
    component: Layout,
    meta: { title: '会务中心', directory: true, icon: require('@/assets/menu-icon/会务中心（未选中）.png'), activeIcon: require('@/assets/menu-icon/会务中心（选中）.png') },
    children: [
      {
        name: '/meeting/apply',
        path: '/meeting/apply',
        title: '会议申请',
        meta: { title: '会议申请', icon: require('@/assets/menu-icon/会务中心（未选中）.png'), activeIcon: require('@/assets/menu-icon/会务中心（选中）.png') },
        component: () => import('@/views/meeting/apply')
      },
      {
        name: '/meeting/process',
        path: '/meeting/process',
        title: '会议进程',
        meta: { title: '会议进程', icon: require('@/assets/menu-icon/会务中心（未选中）.png'), activeIcon: require('@/assets/menu-icon/会务中心（选中）.png') },
        component: () => import('@/views/meeting/process')
      }
    ]
  },
  {
    name: '/professor-lib',
    path: '/professor-lib',
    redirect: '/professor-lib/professor-lib',
    component: Layout,
    meta: { title: '专家智库', icon: require('@/assets/menu-icon/专家智库（未选中）.png'), activeIcon: require('@/assets/menu-icon/专家智库（选中）.png') },
    children: [
      {
        name: '/professor-lib/professor-lib',
        path: '/professor-lib/professor-lib',
        meta: { title: '专家智库', directory: true, icon: require('@/assets/menu-icon/专家智库（未选中）.png'), activeIcon: require('@/assets/menu-icon/专家智库（选中）.png') },
        component: () => import('@/views/professor-lib')
      }
    ]
  },
  {
    name: '/cloud-audit',
    path: '/cloud-audit',
    redirect: '/cloud-audit/cloud-audit',
    component: Layout,
    meta: { title: '云上联审', icon: require('@/assets/menu-icon/云上联审（未选中）.png'), activeIcon: require('@/assets/menu-icon/云上联审（选中）.png') },
    children: [
      {
        name: '/cloud-audit/cloud-audit',
        path: '/cloud-audit/cloud-audit',
        meta: { title: '云上联审', directory: true, icon: require('@/assets/menu-icon/云上联审（未选中）.png'), activeIcon: require('@/assets/menu-icon/云上联审（选中）.png') },
        component: () => import('@/views/cloud-audit')
      }
    ]
  },
  {
    name: '/enterprise',
    path: '/enterprise',
    redirect: '/enterprise/enterprise',
    component: Layout,
    meta: { title: '企业管理', directory: true, icon: require('@/assets/menu-icon/项目中心（未选中）.png'), activeIcon: require('@/assets/menu-icon/项目中心（选中）.png') },
    children: [
      {
        name: '/enterprise/enterprise',
        path: '/enterprise/enterprise',
        meta: { title: '企业管理', icon: require('@/assets/menu-icon/项目中心（未选中）.png'), activeIcon: require('@/assets/menu-icon/项目中心（选中）.png') },
        component: () => import('@/views/enterprise/enterprise')
      },
      {
        name: '/enterprise/audit',
        path: '/enterprise/audit',
        meta: { title: '企业审核', icon: require('@/assets/menu-icon/项目中心（未选中）.png'), activeIcon: require('@/assets/menu-icon/项目中心（选中）.png') },
        component: () => import('@/views/enterprise/audit')
      },
      {
        name: '/enterprise/account',
        path: '/enterprise/account',
        meta: { title: '企业账号', icon: require('@/assets/menu-icon/项目中心（未选中）.png'), activeIcon: require('@/assets/menu-icon/项目中心（选中）.png') },
        component: () => import('@/views/enterprise/account')
      }
    ]
  },
  {
    name: '/enterprise-project',
    path: '/enterprise-project',
    redirect: '/enterprise-project/project',
    component: Layout,
    meta: { title: '企业中心', directory: true, icon: require('@/assets/menu-icon/项目中心（未选中）.png'), activeIcon: require('@/assets/menu-icon/项目中心（选中）.png') },
    children: [
      {
        name: '/enterprise-project/project',
        path: '/enterprise-project/project',
        meta: { title: '项目中心', icon: require('@/assets/menu-icon/项目中心（未选中）.png'), activeIcon: require('@/assets/menu-icon/项目中心（选中）.png') },
        component: () => import('@/views/enterprise/project')
      },
      // {
      //   name: '/enterprise-project/engineering',
      //   path: '/enterprise-project/engineering',
      //   meta: { title: '工程中心', icon: require('@/assets/menu-icon/项目中心（未选中）.png'), activeIcon: require('@/assets/menu-icon/项目中心（选中）.png') },
      //   component: () => import('@/views/enterprise/engineering')
      // },
      {
        name: '/enterprise-project/file',
        path: '/enterprise-project/file',
        meta: { title: '文件上传记录', icon: require('@/assets/menu-icon/项目中心（未选中）.png'), activeIcon: require('@/assets/menu-icon/项目中心（选中）.png') },
        component: () => import('@/views/enterprise/file')
      }
    ]
  },
  {
    name: '/system',
    path: '/system',
    component: Layout,
    meta: { title: '系统设置', directory: true, icon: require('@/assets/menu-icon/配置管理（未选中）.png'), activeIcon: require('@/assets/menu-icon/配置管理（选中）.png') },
    children: [
      {
        name: '/system/dept',
        path: '/system/dept',
        meta: { title: '单位管理', icon: require('@/assets/menu-icon/配置管理（未选中）.png'), activeIcon: require('@/assets/menu-icon/配置管理（选中）.png') },
        component: () => import('@/views/system/dept')
      },
      {
        name: '/system/user-info',
        path: '/system/user-info',
        hidden: true,
        meta: { title: '用户资料', icon: require('@/assets/menu-icon/配置管理（未选中）.png'), activeIcon: require('@/assets/menu-icon/配置管理（选中）.png') },
        component: () => import('@/views/system/user/user-info')
      },
      {
        name: '/system/user',
        path: '/system/user',
        meta: { title: '用户管理', icon: require('@/assets/menu-icon/配置管理（未选中）.png'), activeIcon: require('@/assets/menu-icon/配置管理（选中）.png') },
        component: () => import('@/views/system/user')
      },
      {
        name: '/system/permission',
        path: '/system/permission',
        meta: { title: '权限管理', icon: require('@/assets/menu-icon/配置管理（未选中）.png'), activeIcon: require('@/assets/menu-icon/配置管理（选中）.png') },
        component: () => import('@/views/system/permission')
      },
      {
        name: '/system/log',
        path: '/system/log',
        meta: { title: '日志管理', icon: require('@/assets/menu-icon/配置管理（未选中）.png'), activeIcon: require('@/assets/menu-icon/配置管理（选中）.png') },
        component: () => import('@/views/system/log')
      }
    ]
  }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
